<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * Baby 测试类
 */

namespace app\test\controller;

use app\utils\BoyeService;
use app\test\controller\Ava;

class Baby extends Ava {

	//baby delete by id
	public function delete(){
		if(IS_AJAX){
        $data = array(
						'uid'       => I('post.uid',0),
						'id'        => I('post.id',0),
						'api_ver'   =>$this->api_ver,
						'notify_id' =>$this->notify_id,
						'alg'       =>$this->alg,
						'type'      =>'BY_Baby_delete',
        );

        $service = new BoyeService();
        $result = $service->callRemote("",$data,true);
        echo $this->parseResult($result);
    }else{
    	$this->assign('type','BY_Baby_delete');
			$this->assign('field',[
				['api_ver',$this->api_ver,LL('need-mark api version')],
				['uid',42,LL('need-mark user ID')],
				['id',2,LL('need-mark baby ID')],
			]);
	    echo $this->display('ava/test');
    }
	}
	//baby update by id
	public function update(){
		if(IS_AJAX){
        $data = array(
						'uid'       => I('post.uid',0),
						'id'        => I('post.id',0),
						'name'      => I('post.name',''),
						'sex'       => I('post.sex',0),
						'birthday'  => I('post.birthday',0),
						'is_default'=> I('post.is_default',0),
						// 'status'     => I('post.status',0),
						'head'      => I('post.head',0),
						'api_ver'   =>$this->api_ver,
						'notify_id' =>$this->notify_id,
						'alg'       =>$this->alg,
						'type'      =>'BY_Baby_update',
        );

        $service = new BoyeService();
        $result = $service->callRemote("",$data,true);
        echo $this->parseResult($result);
    }else{
    	$this->assign('type','BY_Baby_update');
			$this->assign('field',[
				['api_ver',$this->api_ver,LL('need-mark api version')],
				['uid',42,LL('need-mark user ID')],
				['id',2,LL('need-mark baby ID')],
				['name','',LL('need-mark baby-name')],
				['sex','',L('reg-sex')],
				['birthday','',L('birthday')],
				['is_default','',L('is_default')],
				// ['status','',L('baby_status')],
				['head','',L('head')],
			]);
	    echo $this->display('ava/test');
    }
	}
	//单个宝宝查询
	public function detail(){
		if(IS_AJAX){
        $data = array(
						'uid'       => I('post.uid',0),
						'id'        => I('post.id',0),
						'api_ver'   =>$this->api_ver,
						'notify_id' =>$this->notify_id,
						'alg'       =>$this->alg,
						'type'      =>'BY_Baby_detail',
        );

        $service = new BoyeService();
        $result = $service->callRemote("",$data,true);
        echo $this->parseResult($result);
    }else{
    	$this->assign('type','BY_Baby_detail');
			$this->assign('field',[
				['api_ver',$this->api_ver,LL('need-mark api version')],
				['uid',42,LL('need-mark user ID')],
				['id',2,LL('need-mark baby ID')],
			]);
	    echo $this->display('ava/test');
    }
	}
	//宝宝查询 不分页
	public function query(){
		if(IS_AJAX){
        $data = array(
						'uid'        => I('post.uid',0),
						'api_ver'   =>$this->api_ver,
						'notify_id' =>$this->notify_id,
						'alg'       =>$this->alg,
						'type'      =>'BY_Baby_query',
        );

        $service = new BoyeService();
        $result = $service->callRemote("",$data,true);
        echo $this->parseResult($result);
    }else{
    	$this->assign('type','BY_Baby_query');
    	$this->assign('code_type',5);//验证码类型
			$this->assign('field',[
				['api_ver',$this->api_ver,LL('need-mark api version')],
				['uid',42,LL('need-mark user ID')],
			]);
	    echo $this->display('ava/test');
    }
	}
	//宝宝添加
	public function add(){
		if(IS_AJAX){
        $data = array(
						'uid'        => I('post.uid',0),
						'name'       => I('post.name',''),
						'sex'        => I('post.sex',0),
						'birthday'   => I('post.birthday',0),
						'is_default' => I('post.is_default',0),
						// 'status'     => I('post.status',0),
						'head'       => I('post.head',0),
						'api_ver'   =>$this->api_ver,
						'notify_id' =>$this->notify_id,
						'alg'       =>$this->alg,
						'type'      =>'BY_Baby_add',
        );

        $service = new BoyeService();
        $result = $service->callRemote("",$data,true);
        echo $this->parseResult($result);
    }else{
    	$this->assign('type','BY_Baby_add');
    	$this->assign('code_type',5);//验证码类型
			$this->assign('field',[
				['api_ver',$this->api_ver,LL('need-mark api version')],
				['uid',42,LL('need-mark user ID')],
				['name','',LL('need-mark baby-name')],
				['sex','',L('reg-sex')],
				['birthday','',L('birthday')],
				['is_default','',L('is_default')],
				// ['status','',L('baby_status')],
				['head','',L('head')],
			]);
	    echo $this->display('ava/test');
    }
	}
}